package asia.doing.controller.user;

import asia.doing.common.Result;
import asia.doing.entity.ActivitySign;
import asia.doing.service.user.FrontActivitySignService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController(value = "frontActivitySignController")
@RequestMapping("/front/activitySign")
public class FrontActivitySignController {

    @Resource
    FrontActivitySignService frontActivitySignService;

    @PostMapping("/add")
    public Result add(@RequestBody ActivitySign activitySign) {
        frontActivitySignService.add(activitySign);
        return Result.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id) {
        frontActivitySignService.deleteById(id);
        return Result.success();
    }

    /**
     * 批量删除
     */
    @DeleteMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<Long> ids) {
        frontActivitySignService.deleteBatch(ids);
        return Result.success();
    }

    /**
     * 分页查询
     */
    @GetMapping("/selectPage")
    public Result selectPage(ActivitySign activitySign,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<ActivitySign> page = frontActivitySignService.selectPage(activitySign, pageNum, pageSize);
        return Result.success(page);
    }

}